import React from 'react';
import { Modal } from 'antd';
import { useRequest, defaultFormatResult } from '@/hooks';
import pageTabUtil from '@/utils/pageTabUtil';
import { getInterviewerDetail } from '../../service';

const useBeforeInterview = ({ arrangeId }) => {
    const { data: detail = {} } = useRequest(() => getInterviewerDetail(arrangeId), {
        ...defaultFormatResult
    });

    const { employeeName } = detail;

    const showContent = React.useCallback(() => {
        Modal.warning({
            title: '提醒',
            content: `您已被${employeeName}面谈官设置为缺席，无法填写面谈记录`,
            okText: '确定',
            onOk() {
                pageTabUtil.goBack();
            }
        });
    }, [employeeName]);

    React.useEffect(() => {
        if (employeeName) {
            showContent();
        }
    }, [showContent, employeeName]);
};

export default useBeforeInterview;
